package br.com.projeto.hibernatedao;

import java.util.List;

import org.hibernate.Session;

import br.com.projeto.dao.CategoryDAO;
import br.com.projeto.entities.Category;

public class CategoryHibernateDAO implements CategoryDAO{
	
	private Session session;

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	@Override
	public void saveCategory(Category category) {
		this.session.save(category);		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Category> listAllCategories() {
		return getSession().createCriteria(Category.class).list();
	}

	@Override
	public void updateCategory(Category category) {
		this.session.update(category);
	}

	@Override
	public void deleteCategory(Category category) {
		this.session.delete(category);		
	}

}
